//
//  AppDelegate.m
//  stone-story
//
//  Created by liu dodo on 12-9-23.
//  Copyright (c) 2012年 liu dodo. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate
@synthesize window;
@synthesize requestCount;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    //调用客户化定制界面函数
    [self customizeAppearance];
    requestCount=0;
    
    //2 个key: @”everLaunched”判断用户以前是否登录,@”firstLaunch” 用来开发者在程序的其他部分判断.
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];
    }
    
  
    

    return YES;
}
							
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}



//界面统一修改函数
-(void)customizeAppearance{
    
    //  [[UIView appearance]  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]]];
    
    //create resizable images创建可调整大小的图像
    //使用resizableImageWithCapInsets方法创建了可伸缩的图像
    UIImage *gradientImage44 = [[UIImage imageNamed:@"bartop.jpg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    UIImage *gradientImage32 = [[UIImage imageNamed:@"bartop.jpg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    //set the background image for *all* UINavigationBars为所有导航栏设置背景图片 appearance的外觀
  
    [[UINavigationBar appearance] setBackgroundImage:gradientImage44 forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setBackgroundImage:gradientImage32 forBarMetrics:UIBarMetricsLandscapePhone];
    
    
    
    /*
     
     //customize the apperance for UIBarButtonItems   定制Abaou 的外觀
     
     UIImage *button30 = [[UIImage imageNamed:@"ZS_NavigationLeftBtn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
     UIImage *button24 = [[UIImage imageNamed:@"ZS_NavigationLeftBtn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
     
     [[UIBarButtonItem appearance] setBackgroundImage:button30 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
     [[UIBarButtonItem appearance] setBackgroundImage:button24 forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
     
     
     
     //customize the appeance for "back" on UIBarButtonItems  定制返回的外觀
     
     UIImage *buttonBack30 = [[UIImage imageNamed:@"ZS_NavigationBack.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
     UIImage *buttonBack24 = [[UIImage imageNamed:@"ZS_NavigationBack"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)];
     
     [[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30 forState:
     UIControlStateNormal barMetrics:UIBarMetricsDefault];
     [[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24 forState:
     UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
     
     */
    
    
}


@end
